package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingPlanDto;
import com.zzyl.entity.NursingPlan;
import com.zzyl.mapper.NursingPlanMapper;
import com.zzyl.service.NursingPlanService;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingPlanVo;
import com.zzyl.vo.NursingProjectVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;

@Service
@Slf4j
public class NursingPlanIServicempl implements NursingPlanService {

    @Autowired
    private NursingPlanMapper nursingPlanMapper;


    @Autowired
    private NursingProjectService nursingProjectService;
    @Override
    public List<NursingPlanVo> getNursingPlan() {
        List<NursingPlanVo> nursingPlanVoList = nursingPlanMapper.selectAll();

        NursingPlanVo nursingPlanVo = BeanUtil.toBean(nursingPlanVoList, NursingPlanVo.class);
        return nursingPlanVoList;

    }

    @Override
    public NursingPlanVo getbyid(Long id) {
        NursingPlan nursingPlan = nursingPlanMapper.getbyid(id);

        NursingPlanVo nursingPlanvo = BeanUtil.toBean(nursingPlan, NursingPlanVo.class);


        return nursingPlanvo;
    }


    @Override
    public void updateNursingPlan(NursingPlanDto nursingPlan) {
        NursingPlan nursingPlan1 = BeanUtil.toBean(nursingPlan, NursingPlan.class);

        NursingPlanVo byId = getbyid(nursingPlan1.getId());

        nursingPlanMapper.update(nursingPlan1);

    }

    @Override
    public void getNursingPlanStatus(Long id, Integer status) {
    nursingPlanMapper.updateStatus(id,status);




    }

    @Override
    public String listByPage(String name, Integer status, Integer pageNum, Integer pageSize) {

        PageHelper.startPage(pageNum,pageSize);
        List<NursingPlanVo> nursingPlanVoList = nursingPlanMapper.selectByPage(name,status,pageNum,pageSize);
        Page<NursingPlanVo> nursingPlanVoPage = (Page<NursingPlanVo>) nursingPlanVoList;
        return nursingPlanVoPage.toString();

    }
}



